package easy.回文数;

public class Solution {
    public boolean isPalindrome(int x) {
        if (x < 0 || x % 10 == 0 && x != 0) {
            return false;
        }
        int revertedNumber = 0;
        while (x > revertedNumber) {
            //remainder余数
            int remainder = x % 10;
            revertedNumber = revertedNumber * 10 + remainder;
            x = x / 10;
        }
        // 由于处于中位的数字不影响回文（它总是与自己相等），所以我们可以简单地将其去除。
        return x == revertedNumber || x == revertedNumber / 10;
    }

    public static void main(String[] args) {
        int x = 0;
        Solution solution = new Solution();
        System.out.println(solution.isPalindrome(x));
    }
}
